package lib.bone.access.module.dict.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.Hibernate;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;
import java.util.Objects;

/**
 * @Author : cg
 * @Date : 2022-1-13
 * 维护横向课题关系词典
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "nepu_subject_dict")
@EntityListeners(AuditingEntityListener.class)
@ApiModel(value = "横向课题词典")
public class NepuSubjectDict {

    @Id
    @GeneratedValue(generator = "jpa-uuid")
    @ApiModelProperty(value = "横向课题词典ID",name = "id")
    String id;
    /**
     * 词典编码
     */
    @ApiModelProperty("词典编码")
    @Column(name = "code")
    String code;
    /**
     * 横向课题类型
     */
    @ApiModelProperty(value = "横向课题类型",notes = "自然科学，社会科学")
    @Column(name = "subject_type")
    String subjectType;

    /**
     * 横向课题级别
     */
    @ApiModelProperty(value = "横向课题级别",notes = "A1,A2,B1等")
    @Column(name = "subject_level")
    String subjectLevel;

    @ApiModelProperty("经费上限")
    @Column(name = "founds_ceiling",scale = 2)
    Double fundsCeiling;

    @ApiModelProperty("经费下限")
    @Column(name = "founds_floor",scale = 2)
    Double fundsFloor;

    /**
     * 横向课题年工作量
     */
    @ApiModelProperty(value = "工作量Min",notes = "获奖对应的最小工作量")
    @Column(name = "workload_min")
    Integer workloadMin;
    @ApiModelProperty(value = "工作量Max",notes = "获奖对应的最大工作量")
    @Column(name = "workload_max",scale = 2)
    Double workloadMax;

    @ApiModelProperty(value = "横向课题词典备注")
    @Column(name = "remark")
    String remark;

    @CreatedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "记录创建时间",name = "createdTime")
    @Column(name = "created_time")
    private Date createdTime;
    @LastModifiedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "记录更新时间",name = "updatedTime")
    @Column(name = "updated_time")
    private Date updatedTime;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        NepuTopicDict nepuTopicDict = (NepuTopicDict) o;
        return id != null && Objects.equals(id, nepuTopicDict.id);
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
